<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- <%@ page import="java.text.SimpleDateFormat"%>  --%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>查询订单明细</title>
<%@ include file="/common/importLib.jsp" %>
<script type="text/javascript" src="../common/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">

	/**
	 * 增删改查参数设置
	 */
	/* toolbarView = 0;
	tableWidth = "100%";
	tableHeight = $(window).height()-110; */
	tableTitle = "在线答疑";
	toolbarView = 5;
	tableURL = getTimeURL("../queries/questionInfo/questionListBack.do");
	tableColumns = [[{field:'ck',checkbox:true},
	                {field:'id',title:'id',width:0},
	                {field:'userName',title:'提问人',width:180},
					{field:'questionContent',title:'提问内容',width:180},
					{field:'imgArray',title:'提问附图',width:250,
						formatter:function(value,rowData,rowIndex){
							if (rowData.imgArray && rowData.imgArray.length !=0) {
								var $imgList = $("<div></div>");
								for(var i=0;i<rowData.imgArray.length;i++){
									var $img = $("<img />").css({
										'width':'70px',
										'height':'60px',
										'padding':'5px',
									})
									var url=mrjyFile + "question/" + rowData.imgArray[i]+"?"+new Date().getTime();
									$img.attr({
										"src":url,
										'onClick':"viewPic('" + url + "')",
									})
									$imgList.append($img);
								}
								return $imgList.html();
							}else{
								return "";
							}
						}},
					{field:'typeName',title:'问题阶段',width:180},
					{field:'questionTimeString',title:'提问时间',width:150},
					{field:'commentNum',title:'评论数',width:100},
					{field:'goodNum',title:'点赞数',width:100},
					{field:'priority',title:'置顶操作',width:150,align:'center',rowspan:1,
						 formatter:function(value,rowData,rowIndex){
							if(rowData.priority == 0){
								return "<a class='stick-status' href='javascript:stick(\"stick\","+ rowData.id +")'>置顶</a>";
							}else{
								return "<a class='unstick-status' href='javascript:stick(\"reset\","+ rowData.id +")'>取消置顶</a><a class='stick-status' href='javascript:stick(\"stick\","+ rowData.id +")'>置顶</a>";
							}
						 }
					},
					{field:'disableFlag',title:'禁用状态',width:80,align:'center', rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.disableFlag == 0){
								return "<font color='green'>起用</font>";
							}else{
								return "<font color='red'>禁用</font>";
							}
						}
					}]];
	var addWidth = 700; //添加窗口宽度
	var addHeight = 350; //添加窗口高度
	var addTitle = "发布问题"; //添加标题
	var updateDisableFlagUri = "../queries/questionInfo/updateDisableFlag.do"; //禁用、起用记录
	
	$(function(){
		//combobox_1("statusId","../payment/userBalance/getOrderStatusList.do",true);
		//combobox_1("paymentMethod","../payment/userBalance/getPayMethodList.do",false);
		combobox_select_event("typeId","../queries/questionInfo/getStageList.do",false,null,function(value){
			searchTable();
		});
	});
	
	/**
	 * 初始化添加表单
	 */	
	function initAddForm(){	
		//打开照片上传组件
		//uploadMoreFile("uploadFile","/mrjy_file/questionFile/questionInfo/uploadBack.do","2000KB",100,30,"uploadMessage","backup/maintain/schoolpic/","imgArray","imgContainer");
		//$("#roleId").val("4");
		//addFormProcess("loginCode","用户",true);	
		//ajaxFormValidator("loginCode","账号",1,16,"userInfo/loginCodeValidate.do","ascii");
		//ajaxFormValidator("mobilePhone","手机",11,11,"userInfo/mobilePhoneValidate.do");
		//baseFormValidator("userName","姓名",2,12,"chinese");
		//baseFormValidator("mobilePhone","电话",11,11,"mobile");
	}
	
	function stick(value,id){
		var action = "";
		if('reset' == value){
			action = "取消置顶";
		}else{
			action = "置顶"
		}
		$.messager.confirm(action+'提醒', '是否'+ action +'该问题？' ,function(r){
			if(r){
				$.getJSON(getTimeURL("../queries/questionInfo/updateStickStatus.do"),{stickStatus:value,id:id},function(data){
					if(data=="ok"){
						$('#datagrid_table').datagrid('reload');
					}else{
						$.messager.alert('提示',action+ '失败!请确保该问题已起用!否则稍后重试或联系管理员');
					}
				})
			}
		});
	}
	
</script>
<style type="text/css">
	.stick-status{
		margin:auto 15px;
	}
	.unstick-status{
		margin:auto 15px;
		color:red;
	}
	#datagrid_add,#datagrid_update{
		padding:  10px 20px;
	}
	#datagrid_add tr,#datagrid_update tr{
	    height: 30px;
	}
</style>
</head>

<body id="layout" class="easyui-layout">
	 <div style="background: none repeat scroll 0% 0% #EFEFEF; height:100px; padding: 6px 2px; border-bottom: 1px solid #CCC;"
		region="north"  split="false" title="条件查询">
	<form  id="searchForm" >
	 <table>
		<tr>
			<td width ="30px;"></td>
			<td>提问时间：</td>
			<td><input type="text" name="startTime" id="starttime" style="width: 86px;" class="input-style" onclick="WdatePicker({el:'starttime',maxDate:'#F{$dp.$D(\'endtime\')}'})"/>
				<span style="padding: 0 6px 0 2px;">至</span><input type="text" name ="endTime" id="endtime"  style="width: 86px;" class="input-style" onclick="WdatePicker({el:'endtime',minDate:'#F{$dp.$D(\'starttime\')}'})"/></td>
			<td width="50px;"></td>
			<td>问题类型：</td>
			<td><input type="text" name="typeId" id="typeId"/></td>
		</tr>
		<tr>		
			<td width ="30px;"></td>
			<td>问题内容：</td>
			<td><input type="text" name="questionContent" id="questionContent"/></td>			
			<td width="80px;"></td>
			<td><a class="easyui-linkbutton" id="search" iconCLs="icon-search"  onclick="searchTable();">搜索</a></td>
		</tr>
	</table>
	</form>
	</div>
	<div region="center">
	<!-- datagrid信息表 -->
	<table id="datagrid_table"></table>
	<!-- 添加记录 -->
	<div id="datagrid_add">
		<form id="add_form" action="userInfo/maintainAddUserInfo.do" method="post">			
			<input type ="hidden" id="imgArray" name="imgArray">
			<table width="630" class="xxl_tb_1">
				<tbody>	
					<tr>
						<td width="120" class="xxl_td_2">账号：</td>
						<td ><input type="text" id="loginCode" name="loginCode" onchange="validateSubmitOnce=true"/></td>
						<td><div id="loginCodeTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">姓名：</td>
						<td><input type="text" id="userName" name="userName"/></td>
						<td><div id="userNameTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td  class="xxl_file_td_1">照片：</td>
						<td id="imgContainer">
							<div class="div"><input id='uploadFile' type='file' name='uploadFile'/><span id='uploadMessage'></span>
							</div>
							<img style="height: 80px;width: 80px;" src=""/>
							<!--  <div id="">
								<img style="height: 80px;width: 80px;" src=""/>
							</div>-->
						</td>
						<td ><div style="color:red"> *照片后缀名为png，格式为200*200px</div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">手机号码：</td>
						<td><input type="text" id="mobilePhone" name="mobilePhone" maxlength="11" onchange="validateSubmitOnce=true"/></td>
						<td><div id="mobilePhoneTip" style="width:250px"></div></td>
					</tr>
					
					<tr>
						<td colspan="3" style="text-align: center">					
							<a class="easyui-linkbutton" iconCls="icon-ok" onclick="$('#add_form').submit();">添加</a>
							<a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('add_form').reset()">重置</a>
							<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#datagrid_add').window('close');">取消</a>
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	</div>
	</div>
</body>
</html>